library(Seurat)
Registered S3 method overwritten by 'data.table':
  method           from
  print.data.table     
Registered S3 method overwritten by 'htmlwidgets':
  method           from         
  print.htmlwidget tools:rstudio
Attaching SeuratObject
library(SeuratDisk)
Registered S3 method overwritten by 'SeuratDisk':
  method            from  
  as.sparse.H5Group Seurat
library(reticulate)
Warning: package ‘reticulate’ was built under R version 4.3.1
library(scrubletR)
library(ggplot2)
library(patchwork)
library(dplyr)

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union
library(data.table)
data.table 1.14.8 using 4 threads (see ?getDTthreads).  Latest news: r-datatable.com

Attaching package: ‘data.table’

The following objects are masked from ‘package:dplyr’:

    between, first, last
library(clustree)
Warning: package ‘clustree’ was built under R version 4.3.1Loading required package: ggraph
Warning: package ‘ggraph’ was built under R version 4.3.1
library(reshape2)

Attaching package: ‘reshape2’

The following objects are masked from ‘package:data.table’:

    dcast, melt
library(tidyr)

Attaching package: ‘tidyr’

The following object is masked from ‘package:reshape2’:

    smiths
library(gridExtra)
Warning: package ‘gridExtra’ was built under R version 4.3.3
Attaching package: ‘gridExtra’

The following object is masked from ‘package:dplyr’:

    combine
library(stringr)
Warning: package ‘stringr’ was built under R version 4.3.1
library(plyr)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
You have loaded plyr after dplyr - this is likely to cause problems.
If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
library(plyr); library(dplyr)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Attaching package: ‘plyr’

The following objects are masked from ‘package:dplyr’:

    arrange, count, desc, failwith, id, mutate, rename, summarise, summarize
source("C:/Ryan/GitHub/trachtenberg-lab/transcriptomics/tools/seurat_functions.R")
source("C:/Ryan/GitHub/trachtenberg-lab/transcriptomics/tools/seurat_integration_functions.R")
source("C:/Ryan/GitHub/trachtenberg-lab/transcriptomics/xgboost/xgboost_train.R")
source("C:/Ryan/GitHub/trachtenberg-lab/transcriptomics/xgboost/plottingFxns.R")

obj.opossum.gabaergic <- readRDS("E:/Transcriptomics_V1/Opossum/seurat/opossum_v1_gabaergic_processed.rds")
obj.opossum.gabaergic$species <- "Opossum"
subclass.markers.opossum.gabaergic <- readRDS("E:/Transcriptomics_V1/Opossum/seurat/marker_genes/GABAergic/markerdict_subclass.rds")
markers.opossum.gabaergic <- readRDS("E:/Transcriptomics_V1/Opossum/seurat/marker_genes/GABAergic/markerdict_types.rds")
obj.mouse.gabaergic.P38 <- readRDS("E:/Transcriptomics_V1/Mouse/seurat/mouse_v1_P38_gabaergic_processed.rds")
obj.mouse.gabaergic.P38$species <- "Mouse"
subclass.markers.mouse.gabaergic.P38 <- readRDS("E:/Transcriptomics_V1/Mouse/seurat/marker_genes/GABAergic/P38/markerdict_subclass.rds")
markers.mouse.gabaergic.P38 <- readRDS("E:/Transcriptomics_V1/Mouse/seurat/marker_genes/GABAergic/P38/markerdict_types.rds")

objs <- list(obj.opossum.gabaergic, obj.mouse.gabaergic.P38)
subclass.markers <- list(subclass.markers.opossum.gabaergic, subclass.markers.mouse.gabaergic.P38)
type.markers <- list(markers.opossum.gabaergic, markers.mouse.gabaergic.P38)
sample.names <- list("OpossumV1", "MouseV1-P38")

subclasses <- c("Pvalb", "Sst", "Vip", "Lamp5", "Frem1", "Stac")

# pre-integration subclass comparison (DE genes)
for (pc in c(T, F)) {
  p <- PlotSubclassDEIntersection(subclass.markers[[1]], subclass.markers[[2]], 
                                  rownames(objs[[1]]), rownames(objs[[2]]),
                                  sample.names[[1]], sample.names[[2]],
                                  subclasses, 0.2, "E:/Transcriptomics_V1/Integration/Opossum_Mouse-P38/subclass_markers/GABAergic/", percentage = pc)
  print(p)
}
Warning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
Please use `linewidth` instead.

# pre-integration type comparison (DE genes)
for (pc in c(T, F)) {
  for (sbcl in subclasses) {
    if (sbcl %in% names(type.markers[[1]]) & sbcl %in% names(type.markers[[2]])) {
      p <- PlotIdentDEIntersection(type.markers[[1]], type.markers[[2]],
                                   rownames(objs[[1]]), rownames(objs[[2]]),
                                   sample.names[[1]], sample.names[[2]],
                                   sbcl, sbcl, "type", "type", 0.2, percentage = pc)
      print(p)
    }
  }
}


sbcl_conf_plots <- PlotSubclassCrossConfusionMatrices(objs[[1]], objs[[2]], 
                                                      sample.names[[1]], sample.names[[2]], 
                                                      assay = "SCT",
                                                      subclasses, n_iters = 10, all.genes = FALSE, upsample = TRUE)
Warning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: package ‘xgboost’ was built under R version 4.3.1
Attaching package: ‘xgboost’

The following object is masked from ‘package:dplyr’:

    slice

Warning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer range


print(sbcl_conf_plots[[1]])

print(sbcl_conf_plots[[2]])


subclass.labels <- c("Pvalb", "Sst", "Vip")
ident.labels <- c("type")

idnt_conf_plots <- PlotIdentCrossConfusionMatrices(objs[[1]], objs[[2]], 
                                                   sample.names[[1]], sample.names[[2]], 
                                                   assay = "SCT",
                                                   subclass.labels, ident.labels, n_iters = 10, 
                                                   ident.genes = TRUE, all.genes = FALSE, upsample = TRUE)
[1] "Using IntegrationFeatures from the Ident level..."
[1] "Using IntegrationFeatures from the Ident level..."
[1] "Using IntegrationFeatures from the Ident level..."


for (sbcl in subclass.labels) {
  for (id in ident.labels) {
    print(idnt_conf_plots[[sbcl]][[id]][["avg1"]])
    print(idnt_conf_plots[[sbcl]][[id]][["avg2"]])
  }
}


obj.integrated <- IntegrateObjects(objs[[1]], objs[[2]], resolutions = c(1, 2), nfeatures = 3000, subsample = TRUE)

  |                                                  | 0 % ~calculating  
  |+++++++++++++++++++++++++                         | 50% ~01s          
  |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=02s  
Finding all pairwise anchors

  |                                                  | 0 % ~calculating  
Running CCA
Merging objects
Finding neighborhoods
Finding anchors
    Found 4357 anchors
Filtering anchors
    Retained 3444 anchors

  |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=19s  
sct.model: model1
Setting min_variance based on median UMI:  0.04
Calculating residuals of type pearson for 6513 genes

  |                                                                                                                                                                                                 
  |                                                                                                                                                                                           |   0%
  |                                                                                                                                                                                                 
  |=======                                                                                                                                                                                    |   4%
  |                                                                                                                                                                                                 
  |==============                                                                                                                                                                             |   8%
  |                                                                                                                                                                                                 
  |======================                                                                                                                                                                     |  12%
  |                                                                                                                                                                                                 
  |=============================                                                                                                                                                              |  15%
  |                                                                                                                                                                                                 
  |====================================                                                                                                                                                       |  19%
  |                                                                                                                                                                                                 
  |===========================================                                                                                                                                                |  23%
  |                                                                                                                                                                                                 
  |==================================================                                                                                                                                         |  27%
  |                                                                                                                                                                                                 
  |==========================================================                                                                                                                                 |  31%
  |                                                                                                                                                                                                 
  |=================================================================                                                                                                                          |  35%
  |                                                                                                                                                                                                 
  |========================================================================                                                                                                                   |  38%
  |                                                                                                                                                                                                 
  |===============================================================================                                                                                                            |  42%
  |                                                                                                                                                                                                 
  |======================================================================================                                                                                                     |  46%
  |                                                                                                                                                                                                 
  |==============================================================================================                                                                                             |  50%
  |                                                                                                                                                                                                 
  |=====================================================================================================                                                                                      |  54%
  |                                                                                                                                                                                                 
  |============================================================================================================                                                                               |  58%
  |                                                                                                                                                                                                 
  |===================================================================================================================                                                                        |  62%
  |                                                                                                                                                                                                 
  |==========================================================================================================================                                                                 |  65%
  |                                                                                                                                                                                                 
  |=================================================================================================================================                                                          |  69%
  |                                                                                                                                                                                                 
  |=========================================================================================================================================                                                  |  73%
  |                                                                                                                                                                                                 
  |================================================================================================================================================                                           |  77%
  |                                                                                                                                                                                                 
  |=======================================================================================================================================================                                    |  81%
  |                                                                                                                                                                                                 
  |==============================================================================================================================================================                             |  85%
  |                                                                                                                                                                                                 
  |=====================================================================================================================================================================                      |  88%
  |                                                                                                                                                                                                 
  |=============================================================================================================================================================================              |  92%
  |                                                                                                                                                                                                 
  |====================================================================================================================================================================================       |  96%
  |                                                                                                                                                                                                 
  |===========================================================================================================================================================================================| 100%
sct.model: model1
Setting min_variance based on median UMI:  0.04
Calculating residuals of type pearson for 6513 genes

  |                                                                                                                                                                                                 
  |                                                                                                                                                                                           |   0%
  |                                                                                                                                                                                                 
  |=======                                                                                                                                                                                    |   4%
  |                                                                                                                                                                                                 
  |==============                                                                                                                                                                             |   8%
  |                                                                                                                                                                                                 
  |======================                                                                                                                                                                     |  12%
  |                                                                                                                                                                                                 
  |=============================                                                                                                                                                              |  15%
  |                                                                                                                                                                                                 
  |====================================                                                                                                                                                       |  19%
  |                                                                                                                                                                                                 
  |===========================================                                                                                                                                                |  23%
  |                                                                                                                                                                                                 
  |==================================================                                                                                                                                         |  27%
  |                                                                                                                                                                                                 
  |==========================================================                                                                                                                                 |  31%
  |                                                                                                                                                                                                 
  |=================================================================                                                                                                                          |  35%
  |                                                                                                                                                                                                 
  |========================================================================                                                                                                                   |  38%
  |                                                                                                                                                                                                 
  |===============================================================================                                                                                                            |  42%
  |                                                                                                                                                                                                 
  |======================================================================================                                                                                                     |  46%
  |                                                                                                                                                                                                 
  |==============================================================================================                                                                                             |  50%
  |                                                                                                                                                                                                 
  |=====================================================================================================                                                                                      |  54%
  |                                                                                                                                                                                                 
  |============================================================================================================                                                                               |  58%
  |                                                                                                                                                                                                 
  |===================================================================================================================                                                                        |  62%
  |                                                                                                                                                                                                 
  |==========================================================================================================================                                                                 |  65%
  |                                                                                                                                                                                                 
  |=================================================================================================================================                                                          |  69%
  |                                                                                                                                                                                                 
  |=========================================================================================================================================                                                  |  73%
  |                                                                                                                                                                                                 
  |================================================================================================================================================                                           |  77%
  |                                                                                                                                                                                                 
  |=======================================================================================================================================================                                    |  81%
  |                                                                                                                                                                                                 
  |==============================================================================================================================================================                             |  85%
  |                                                                                                                                                                                                 
  |=====================================================================================================================================================================                      |  88%
  |                                                                                                                                                                                                 
  |=============================================================================================================================================================================              |  92%
  |                                                                                                                                                                                                 
  |====================================================================================================================================================================================       |  96%
  |                                                                                                                                                                                                 
  |===========================================================================================================================================================================================| 100%
Merging dataset 2 into 1
Extracting anchors for merged samples
Finding integration vectors
Finding integration vector weights
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Integrating data
Warning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer range

PlotIntegration(obj.integrated, "species", c("integrated_snn_res.1", "integrated_snn_res.2"), subclasses)


objs.i <- SplitObject(obj.integrated, split.by = "species")

sbcl_conf_plots_i <- PlotSubclassCrossConfusionMatrices(objs.i[[1]], objs.i[[2]], 
                                                        sample.names[[1]], sample.names[[2]], 
                                                        assay = "integrated",
                                                        subclasses, n_iters = 10, all.genes = FALSE, upsample = TRUE)
Warning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer range


print(sbcl_conf_plots_i[[1]])

print(sbcl_conf_plots_i[[2]])


subclass.labels <- c("Pvalb", "Sst", "Vip")
ident.labels <- c("type")

idnt_conf_plots_i <- PlotIdentCrossConfusionMatrices(objs.i[[1]], objs.i[[2]], 
                                                     sample.names[[1]], sample.names[[2]], 
                                                     assay = "integrated",
                                                     subclass.labels, ident.labels, n_iters = 10, 
                                                     ident.genes = TRUE, all.genes = FALSE, upsample = TRUE)
[1] "Using IntegrationFeatures from the Ident level..."
Warning: Not all features provided are in this Assay object, removing the following feature(s): Ush1c, Uaca, Ntsr1, Cdh16, Aldh1a3, Ltf, Cenpf, Trp63, Tdrd1, Ptpn20, Ndc80, Dlk1, Slc5a11, Vwa7, Commd1, Zhx1, Tnnt2, Ribc2, Fam178b, Cpz, Frem3, Shcbp1, Rnasek, Satl1, Pik3r5, Cnga3, Ghrh, Abcb6, Pdlim4, Bco1, Nr0b1, Bnc1, Tmem42, Cd4, Ebi3, Ptgr1, Tmem182, Cpvl, 1810020O05Rik, Fbln7, Kdelr3, Mael, Hhip, Obscn, Xrra1, Gm6657, Pkd1l1, Gadl1, Azgp1, Aspg, Tor4a, Ano7, Cyp27a1, Nme3, Tktl2, Rnase1, Tcea3, Tinag, Pudp, Chkb, Cel, Glipr2, Phf19, Rnf139, Ing4, Zfp488, Pbp2, Fermt1, Ppt2, Cd5, Dscc1, Mylk4, Pdzd9, Prnp, Ikzf1, Pik3ap1, Tm4sf20, Wnt9b, Alox15, Traf3ip3, Sec31b, Tcf7, Cbx6, Tpte, Catsper4, Klk11, Ccdc158, Zc3h11a, Lypla1Warning: Not all features provided are in this Assay object, removing the following feature(s): Ush1c, Uaca, Ntsr1, Cdh16, Aldh1a3, Ltf, Cenpf, Trp63, Tdrd1, Ptpn20, Ndc80, Dlk1, Slc5a11, Vwa7, Commd1, Zhx1, Tnnt2, Ribc2, Fam178b, Cpz, Frem3, Shcbp1, Rnasek, Satl1, Pik3r5, Cnga3, Ghrh, Abcb6, Pdlim4, Bco1, Nr0b1, Bnc1, Tmem42, Cd4, Ebi3, Ptgr1, Tmem182, Cpvl, 1810020O05Rik, Fbln7, Kdelr3, Mael, Hhip, Obscn, Xrra1, Gm6657, Pkd1l1, Gadl1, Azgp1, Aspg, Tor4a, Ano7, Cyp27a1, Nme3, Tktl2, Rnase1, Tcea3, Tinag, Pudp, Chkb, Cel, Glipr2, Phf19, Rnf139, Ing4, Zfp488, Pbp2, Fermt1, Ppt2, Cd5, Dscc1, Mylk4, Pdzd9, Prnp, Ikzf1, Pik3ap1, Tm4sf20, Wnt9b, Alox15, Traf3ip3, Sec31b, Tcf7, Cbx6, Tpte, Catsper4, Klk11, Ccdc158, Zc3h11a, Lypla1
[1] "Using IntegrationFeatures from the Ident level..."
[1] "Using IntegrationFeatures from the Ident level..."


for (sbcl in subclass.labels) {
  for (id in ident.labels) {
    print(idnt_conf_plots_i[[sbcl]][[id]][["avg1"]])
    print(idnt_conf_plots_i[[sbcl]][[id]][["avg2"]])
  }
}


objs.m <- MapObjects(objs.i[[1]], objs.i[[2]], c("subclass", "type"), assay = "integrated")

source("C:/Ryan/GitHub/trachtenberg-lab/transcriptomics/tools/seurat_functions.R")
source("C:/Ryan/GitHub/trachtenberg-lab/transcriptomics/tools/seurat_integration_functions.R")
PlotMapping(objs.m, ident.order = subclasses)

LS0tDQp0aXRsZTogIlIgTm90ZWJvb2siDQpvdXRwdXQ6IGh0bWxfbm90ZWJvb2sNCi0tLQ0KDQoNCmBgYHtyfQ0KDQpsaWJyYXJ5KFNldXJhdCkNCmxpYnJhcnkoU2V1cmF0RGlzaykNCmxpYnJhcnkocmV0aWN1bGF0ZSkNCmxpYnJhcnkoc2NydWJsZXRSKQ0KbGlicmFyeShnZ3Bsb3QyKQ0K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nRlcnNlY3Rpb24odHlwZS5tYXJrZXJzW1sxXV0sIHR5cGUubWFya2Vyc1tbMl1dLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3duYW1lcyhvYmpzW1sxXV0pLCByb3duYW1lcyhvYmpzW1syXV0pLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzYW1wbGUubmFtZXNbWzFdXSwgc2FtcGxlLm5hbWVzW1syXV0sDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNiY2wsIHNiY2wsICJ0eXBlIiwgInR5cGUiLCAwLjIsIHBlcmNlbnRhZ2UgPSBwYykNCiAgICAgIHByaW50KHApDQogICAgfQ0KICB9DQp9DQoNCmBgYA0KDQoNCmBgYHtyLCBmaWcud2lkdGg9MTUsIGZpZy5oZWlnaHQ9Nn0NCg0Kc2JjbF9jb25mX3Bsb3RzIDwtIFBsb3RTdWJjbGFzc0Nyb3NzQ29uZnVzaW9uTWF0cmljZXMob2Jqc1tbMV1dLCBvYmpzW1syXV0sIA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2FtcGxlLm5hbWVzW1sxXV0sIHNhbXBsZS5uYW1lc1tbMl1dLCANCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFzc2F5ID0gIlNDVCIsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJjbGFzc2VzLCBuX2l0ZXJzID0gMTAsIGFsbC5nZW5lcyA9IEZBTFNFLCB1cHNhbXBsZSA9IFRSVUUpDQoNCmBgYA0KDQoNCmBgYHtyfQ0KDQpwcmludChzYmNsX2NvbmZfcGxvdHNbWzFdXSkNCnByaW50KHNiY2xfY29uZl9wbG90c1tbMl1dKQ0KDQpgYGANCg0KDQpgYGB7ciwgZmlnLndpZHRoPTE1LCBmaWcuaGVpZ2h0PTZ9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lbnQubGFiZWxzIDwtIGMoInR5cGUiKQ0KDQppZG50X2NvbmZfcGxvdHNfaSA8LSBQbG90SWRlbnRDcm9zc0NvbmZ1c2lvbk1hdHJpY2VzKG9ianMuaVtbMV1dLCBvYmpzLmlbWzJdXSwgDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNhbXBsZS5uYW1lc1tbMV1dLCBzYW1wbGUubmFtZXNbWzJdXSwgDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFzc2F5ID0gImludGVncmF0ZWQiLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJjbGFzcy5sYWJlbHMsIGlkZW50LmxhYmVscywgbl9pdGVycyA9IDEwLCANCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWRlbnQuZ2VuZXMgPSBUUlVFLCBhbGwuZ2VuZXMgPSBGQUxTRSwgdXBzYW1wbGUgPSBUUlVFKQ0KDQpgYGANCg0KDQpgYGB7cn0NCg0KZm9yIChzYmNsIGluIHN1YmNsYXNzLmxhYmVscykgew0KICBmb3IgKGlkIGluIGlkZW50LmxhYmVscykgew0KICAgIHByaW50KGlkbnRfY29uZl9wbG90c19pW1tzYmNsXV1bW2lkXV1bWyJhdmcxIl1dKQ0KICAgIHByaW50KGlkbnRfY29uZl9wbG90c19pW1tzYmNsXV1bW2lkXV1bWyJhdmcyIl1dKQ0KICB9DQp9DQoNCmBgYA0KDQoNCmBgYHtyfQ0KDQpvYmpzLm0gPC0gTWFwT2JqZWN0cyhvYmpzLmlbWzFdXSwgb2Jqcy5pW1syXV0sIGMoInN1YmNsYXNzIiwgInR5cGUiKSwgYXNzYXkgPSAiaW50ZWdyYXRlZCIpDQoNCmBgYA0KDQoNCmBgYHtyfQ0KDQpQbG90TWFwcGluZyhvYmpzLm0sIGlkZW50Lm9yZGVyID0gc3ViY2xhc3NlcykNCg0KYGBgDQoNCg==